package com.smf.lsc;

import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;

/**
 * 测试controller Created on 2021/11/19.
 *
 * @author ln
 * @since 1.0
 */
@RestController
public class DemoController {

	@RequestMapping(value = "/api")
//	    @PreAuthorize("hasRole('ROLE_USER')")
	public String success() {
		SecurityContext ss = SecurityContextHolder.getContext();
		String s1 = JSON.toJSONString(ss.getAuthentication().getPrincipal());
		return s1;
	}

	@RequestMapping(value = "/test")
	public String test() {
		return "success";
	}
}
